package com.ws.ssmzongjie3.mapper;

import com.ws.ssmzongjie3.bean.UserLikes;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserLikesMapper {
    //根据user_id和route_id删除点赞记录
    @Delete("DELETE FROM user_likes WHERE user_likes_id = #{user_likes_id}")
    int deleteUserLikeById(UserLikes userLikes);
    @Insert("INSERT INTO user_likes(route_id,user_id,like_time) VALUES(#{route_id},#{user_id},now())")
    int insertUserLike(UserLikes userLikes);
    @Select("SELECT * FROM user_likes WHERE user_likes_id = #{user_likes_id}")
    UserLikes getUserLikeById(UserLikes userLikes);
    @Select("SELECT * FROM user_likes WHERE route_id = #{route_id} AND user_id = #{user_id}")
    UserLikes getUserLikeByRouteIdAndUserId(UserLikes userLikes);
    @Delete("DELETE FROM user_likes WHERE route_id = #{route_id} AND user_id = #{user_id}")
    int deleteUserLikeByRouteIdAndUserId(UserLikes userLikes);
    List<UserLikes> listUserLike(UserLikes userLikes);

}
